# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=python2-sphinx
_pkgname=Sphinx
pkgver=1.8.5
pkgrel=6
pkgdesc='Python documentation generator.'
url='https://pypi.org/project/sphinx/#files'
arch=('any')
license=('BSD')
depends=('python2' 'python2-six' 'python2-requests' 'python2-docutils'
         'python2-babel' 'python2-typing' 'python2-imagesize' 'python2-jinja'
         'python2-snowballstemmer' 'python2-sphinx-alabaster-theme'
         'python2-sphinxcontrib-websupport')
makedepends=('python2-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('d7e6a7a6186d1d4e4de0233fb6859da1ef3e02f628512ff9096ef4775b9fb8589edb9052d752925d7a2f1cb7901291af96b5036a5d00f5f58966609bd42872f4')

prepare() {
  cd "$_pkgname-$pkgver"

  find . -name '*.py' |
    xargs sed -i -e 's|/usr/bin/env python|/usr/bin/env python2|' \
    -e 's|/usr/bin/python|/usr/bin/python2|'
}

build() {
  cd "$_pkgname-$pkgver"

  make PYTHON=python2 build
}

package() {
  cd "$_pkgname-$pkgver"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  for i in "$pkgdir/usr/bin/"*; do
    mv $i "${i}2"
  done
}

